package com._520it.crm.service.impl;

import com._520it.crm.domain.InformalStudent;
import com._520it.crm.mapper.InformalStudentMapper;
import com._520it.crm.page.PageResult;
import com._520it.crm.query.InformalStudentQueryObject;
import com._520it.crm.query.QueryObject;
import com._520it.crm.service.IInformalStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * Created by sky on 2017/10/12.
 */
@Service
public class InformalStudentServiceImpl implements IInformalStudentService {
    @Autowired
    private InformalStudentMapper informalStudentMapper;


    public int deleteByPrimaryKey(Long id) {
        return informalStudentMapper.deleteByPrimaryKey(id);
    }

    public int insert(InformalStudent record) {

        return informalStudentMapper.insert(record);
    }

    public InformalStudent selectByPrimaryKey(Long id) {

        return informalStudentMapper.selectByPrimaryKey(id);
    }

    public List<InformalStudent> selectAll() {

        return informalStudentMapper.selectAll();
    }

    public int updateByPrimaryKey(InformalStudent record) {

        return informalStudentMapper.updateByPrimaryKey(record);
    }

    @Override
    public PageResult queryPage(InformalStudentQueryObject qo) {
        return null;
    }

    public PageResult queryPage(QueryObject qo) {

        Integer total = informalStudentMapper.queryForTotal(qo);

                if (total == 0) {
                    new PageResult(0, Collections.EMPTY_LIST);
                }

                List<InformalStudent> rows = informalStudentMapper.queryForRows(qo);

                return new PageResult(total, rows);

    }

    public void quit(Long id) {

    }
}
